package com.gao.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket socket = new ServerSocket(8899);
        Socket accept = socket.accept();
        OutputStream outputStream = accept.getOutputStream();
        InputStream inputStream = accept.getInputStream();
        byte[] bytes = new byte[1024];
        int read = inputStream.read(bytes);
        String msg = new String(bytes, 0, read);
        System.out.println(msg);
        outputStream.write("你也好".getBytes());
        accept.close();
        socket.close();
    }

}
